package com.yangjunli.bishe.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yangjunli.bishe.core.ReturnT;
import com.yangjunli.bishe.entity.CoupleBack;
import com.yangjunli.bishe.mapper.CoupleBackMapper;
import com.yangjunli.bishe.service.ICoupleBackService;
import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.security.SecureRandom;

/**
 * <p>
 *  前端控制器  反馈表
 * </p>
 *
 * @author jobob
 * @since 2020-04-05
 */
@RestController
@RequestMapping("/coupleBack")
@Slf4j
public class CoupleBackController {


    @Autowired
    private ICoupleBackService iCoupleBackService;

    @Resource
    private CoupleBackMapper coupleBackMapper;

    @PostMapping
    public ReturnT saveCoupleBack(@RequestBody CoupleBack coupleBack){
        try {
            coupleBackMapper.insert(coupleBack);
            return new ReturnT(200,"反馈成功");
        }catch (Exception e){
            log.error("saveCoupleBack",e);
            return new ReturnT(100,"操作失败");
        }
    }

    @GetMapping(value = "/{pageNo}/{pageSize}")
    public ReturnT queryCoupleBack(@PathVariable("pageNo") Integer pageNo,@PathVariable("pageSize") Integer pageSize){
        try {
            IPage<CoupleBack> page = new Page<>(pageNo, pageSize);
            IPage<CoupleBack> page1 = iCoupleBackService.page(page);
            return new ReturnT(page1);
        }catch (Exception e){
            log.error("queryCoupleBack",e);
            return new ReturnT(100,"操作失败");
        }
    }

}
